// 模拟后端动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";

/**
 * roles：页面级别权限，这里模拟二种 "admin"、"common"
 * admin：管理员角色
 * common：普通角色
 */
const permissionRouter = {
  path: "/permission",
  meta: {
    title: "menus.permission",
    icon: "ep:lollipop",
    rank: 21
  },
  children: [
    {
      path: "/permission/page/index",
      name: "PermissionPage",
      meta: {
        title: "menus.permissionPage",
        roles: ["admin", "common"]
      }
    },
    {
      path: "/permission/button/index",
      name: "PermissionButton",
      meta: {
        title: "menus.permissionButton",
        roles: ["admin", "common"],
        auths: [
          "permission:btn:add",
          "permission:btn:edit",
          "permission:btn:delete"
        ]
      }
    }
  ]
};

// const chongqingRouter = {
//   path: "/chongqing",
//   redirect: "/chongqing/pfmea_file_manage",
//   meta: {
//     icon: "ri:information-line",
//     // showLink: false,
//     title: "menus.chongqing",
//     rank: 9
//   },
//   children: [
//     {
//       path: "/chongqing/pfmea_file_manage",
//       name: "pfmea_file_manage",
//       component: () => import("@/views/chongqing/pfmea_file_manage.vue"),
//       meta: {
//         title: "menus.pfmea_file_manage",
//         roles: ["admin", "common"]
//       }
//     }
//   ]
// };

export default defineFakeRoute([
  {
    url: "/get-async-routes",
    method: "get",
    response: () => {
      return {
        success: true,
        data: [permissionRouter]
      };
    }
  }
]);
